<?php
/* @var string $input */
/* @var string $src */
/* @var boolean $showPreview */
/* @var array $options */

use yii\helpers\Html;

$options['class'] = 'ajax-file-input';
$options['data-role'] = 'duajaxupload';
?>
<?= Html::beginTag('div', $options) ?>
<div class='input-group'>
    <?= $input ?>
    <span class="input-group-btn">
        <button class="btn btn-default" data-toggle="duajaxupload" type="button" autocomplete="off"><?= Yii::t('da', $label) ?></button>
        <input type="file" style="display: none" />
    </span>
</div>
<div class="ajax-file-input__preview-list">
    <?php if ($src) {
        foreach ($src as $one) {
            $icon = '/images/file-icon.png';
            if (is_array($one)) {
                if ($isImage) {
                    $icon = $one['url'];
                }
                echo Html::tag(
                    'div',
                    Html::img($icon) . '<div class="ajax-file-input__name" title="' . $one['name'] . '">' . $one['name'] . '</div><div class="ajax-file-input__remove"><i class="fa fa-trash"></i></div>',
                    ['class' => 'ajax-file-input__image-preview', 'data-url' => $one['url'], 'data-name' => $one['name']]
                );
            } else {
                if ($isImage) {
                    $icon = $one;
                }
                echo Html::tag('div', Html::img($icon) . '<div class="ajax-file-input__remove"><i class="fa fa-trash"></i></div>', ['class' => 'ajax-file-input__image-preview', 'data-url' => $one]);
            }
        }
    } ?>
</div>
<div class="ajax-file-input__cropper-dialog">
    <div class="ajax-file-input__cropper-content">
        <div class="ajax-file-input__cropper">
            <div class="ajax-file-input__cropper-image-box">
            </div>
        </div>
        <div class="ajax-file-input__cropper-buttons">
            <button type="button" class="btn btn-default" data-dismiss="duajaxupload" autocomplete="off"><?= Yii::t('da', 'Cancel') ?></button>
            <button type="button" class="btn btn-primary" data-upload="duajaxupload" autocomplete="off"><?= Yii::t('da', 'Ok') ?></button>
        </div>
    </div>
</div>
<?= Html::endTag('div') ?>